﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace ClassDAL
{
    /// <summary>
    /// 一些公用的数据访问操作类
    /// </summary>
    public class t_class_Common_DAL
    {
        /// <summary>
        /// 清除上一次的execl文件产生的数据（主要包括老师信息、课程信息、班级信息、排课信息、文件上传信息等）
        /// </summary>
        /// <param name="fileid"></param>
        /// <returns></returns>
        public static int clearExcelUploadFilePreData(int fileid)
        {
            string clearSQL = @"delete from t_class_tearchers where fileId = @fileid;
                                delete from t_class_classes where fileId = @fileid;
                                delete from t_class_course where fileId = @fileid;
                                delete from t_class_grade where fileid = @fileid;
                                delete from t_class_tearcher_course where fileid = @fileid;
                                delete from t_class_schedule where fileid = @fileid;
                                delete from t_user_uploadFile where id = @fileid;";
            
            SqlParameter deleteParam = new SqlParameter() 
            {
                ParameterName = "@fileid",
                Value = fileid
            };


            return SQLHelper.ExecuteNonQuery(SQLHelper.GetConnection(), System.Data.CommandType.Text, clearSQL, deleteParam);
        }
    }
}
